<?php
/**
 * Created by : Sandi Rizky Kharisma (sandi.informatics08@gmail.com)
 * This Class Generated for CRUD purpose only
 */
class m_barang extends CI_Model {
    function __construct() {
        parent::__construct();
    }

    public function jumlah_stok_awal() {
        return $this->db->query("select sum(JUMLAH_AWAL * HARGA_BELI) as total
                        from barang
                        where JUMLAH_AWAL  != 0");
    }

    public function jumlah_stok_akhir() {
        return $this->db->query("select sum(JUMLAH_AKHIR * HARGA_JUAL) as total
                        from barang
                        where JUMLAH_AKHIR  != 0");
    }

    public function get($where = null, $limit = null, $offset = null) {
        if ($where!=null) $this->db->where($where);
        if($limit != null && $offset != null) $this->db->limit($limit, $offset);
        return $this->db->get('barang');
    }
}
?>
